package com.it.controller;

import com.it.service.IUserService;
import com.it.util.Result;
import com.it.vo.LoginVo;
import com.it.vo.RegisterVo;
import com.it.vo.UserInfoVo;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2023-09-22
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    IUserService userService;
    @PostMapping("/login")
    Result<String> userLogin(@RequestBody LoginVo loginVo){
        System.out.println(loginVo);
        String token = userService.login(loginVo);
        return Result.success(token);
    }

    @PostMapping("/register")
    Result<String> register(@RequestBody RegisterVo registerVo){
        userService.register(registerVo);
        return Result.success();
    }
    @PostMapping("/updateUser")
    Result<String> register(@RequestBody UserInfoVo userInfoVo){
        System.out.println(userInfoVo);
        userService.updateUser(userInfoVo);
        return Result.success();
    }

    @DeleteMapping("/logout")
    Result<String> deleteUser(){
        userService.deleteUser();
        return Result.success();
    }

}
